import React, { useRef } from 'react'

/**
 * 
 * 获取dom ,点击聚焦
 */

export default function Test() {
    const iptRef = useRef<HTMLInputElement>(null)

    const handelClick = (e:React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
        iptRef.current?.focus();
    }

    const handelClick2 = () => {
        iptRef.current?.blur();
    }
  return (
      <div>
          <input type="text" ref={ iptRef } />
          <button onClick={handelClick}>点击聚焦</button>
          <button onClick={handelClick2}>点击失去焦点</button>
    </div>
  )
}
